﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package org.aswing {
    import org.aswing.util.*;

    public class KeyMap {

        private var map:HashMap;

        public function KeyMap(){
            this.map = new HashMap();
        }
        public static function getCodec(_arg1:KeyType):String{
            return (getCodecWithKeySequence(_arg1.getCodeSequence()));
        }
        public static function getCodecWithKeySequence(_arg1:Array):String{
            return (_arg1.join("|"));
        }

        public function registerKeyAction(_arg1:KeyType, _arg2:Function):void{
            this.map.put(getCodec(_arg1), new KeyAction(_arg1, _arg2));
        }
        public function unregisterKeyAction(_arg1:KeyType):void{
            this.map.remove(getCodec(_arg1));
        }
        public function getKeyAction(_arg1:KeyType):Function{
            return (this.getKeyActionWithCodec(getCodec(_arg1)));
        }
        private function getKeyActionWithCodec(_arg1:String):Function{
            var _local2:KeyAction = this.map.get(_arg1);
            if (_local2 != null){
                return (_local2.action);
            };
            return (null);
        }
        public function fireKeyAction(_arg1:Array):Boolean{
            var _local2:String = getCodecWithKeySequence(_arg1);
            var _local3:Function = this.getKeyActionWithCodec(_local2);
            if (_local3 != null){
                _local3();
                return (true);
            };
            return (false);
        }
        public function containsKey(_arg1:KeyType):Boolean{
            return (this.map.containsKey(getCodec(_arg1)));
        }

    }
}//package org.aswing 

class KeyAction {

    private var key:KeyType;
    private var action:Function;

    public function KeyAction(_arg1:KeyType, _arg2:Function){
        this.key = _arg1;
        this.action = _arg2;
    }
}
